package tcln.sors.model.core.criteria;

/**
 * All supported search operators.
 * 
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public enum SearchOperator {

    /**
     * Operator: LIKE.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    LIKE("like {0}"),

    /**
     * Operator: IN.
     * <p>
     * <b>Required parameter</b>: many comparing operants.
     */
    IN("in ({0}, {1})"),

    /**
     * Operator: IS NULL.
     * <p>
     * <b>Required parameter</b>: none.
     */
    NULL("is null"),

    /**
     * Operator: IS NOT NULL.
     * <p>
     * <b>Required parameter</b>: none.
     */
    NOT_NULL("is not null"),

    /**
     * Operator: =.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    EQUAL("= {0}"),

    /**
     * Operator: !=.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    NOT_EQUAL("!= {0}"),

    /**
     * Operator: >.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    GREATER_THAN("> {0}"),

    /**
     * Operator: <=.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    NOT_GREATER_THAN("<= {0}"),

    /**
     * Operator: <.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    LESS_THAN("< {0}"),

    /**
     * Operator: >=.
     * <p>
     * <b>Required parameter</b>: comparing operant.
     */
    NOT_LESS_THAN(">= {0}"),

    /**
     * Operator: BETWEEN.
     * <p>
     * <b>Required parameter</b>: 2 comparing operants.
     */
    BETWEEN("between {0} and {1}");

    private String formatPattern;

    private SearchOperator(String formatPattern) {
        this.formatPattern = formatPattern;
    }

    /**
     * Returns current format pattern for toString formatting.
     * 
     * @return 
     */
    public String getFormatPattern() {
        return formatPattern;
    }
}
